package com.lookme.lmtool.cracker.filter.pixellate;

import com.jhlabs.image.ColorHalftoneFilter;
import com.jhlabs.image.EmbossFilter;
import com.jhlabs.image.ImageMath;
import com.lookme.lmtool.cracker.CrackerConstants;
import com.lookme.lmtool.cracker.annotation.FilterAnnotation;
import com.lookme.lmtool.cracker.annotation.ParamAnnotation;
import com.lookme.lmtool.cracker.filter.AbstractFilter;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

import java.awt.image.BufferedImageOp;

@FilterAnnotation(groupName = CrackerConstants.FILTER_GROUP_NAME_PIXELLATE,name="彩色网块",filterClass = ColorHalftoneFilter.class)
public class FilterColorHalftone extends AbstractFilter {
    @XStreamAsAttribute
    @ParamAnnotation(name = "半径", desc = "像素点半径",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,min=1,max=30,blockIncrement = 5,majorTickUnit=10,minorTickCount = 2)
    float dotRadius=2;

    @XStreamAsAttribute
    @ParamAnnotation(name = "青色块角度", desc = "青色块角度",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,max=360,blockIncrement = 5,majorTickUnit=90,minorTickCount = 3)
    private float cyanScreenAngle =108;
    @XStreamAsAttribute
    @ParamAnnotation(name = "洋红块角度", desc = "洋红块角度",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,max=360,blockIncrement = 5,majorTickUnit=90,minorTickCount = 3)
    private float magentaScreenAngle=162;
    @XStreamAsAttribute
    @ParamAnnotation(name = "黄色块角度", desc = "黄色块角度",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,max=360,blockIncrement = 5,majorTickUnit=90,minorTickCount = 3)
    private float yellowScreenAngle=90;

    @Override
    public BufferedImageOp getFilter() {
        ColorHalftoneFilter filter= new ColorHalftoneFilter();
        filter.setdotRadius(dotRadius);
        filter.setCyanScreenAngle((float)Math.toRadians(cyanScreenAngle));
        filter.setMagentaScreenAngle((float)Math.toRadians(magentaScreenAngle));
        filter.setYellowScreenAngle((float)Math.toRadians(yellowScreenAngle));
        return filter;
    }
}
